/**
 * From Microsoft interview
 * convert decimal number to binary
 */
function dec2bin( num ){
    var quot, remainder, bits = [], bin = '';
    do {
        quot = Math.floor(num >> 1);
        remainder = num % 2;
        bits.push(remainder);
        num = quot;
    } while ( num > 0 );
    
    while ( bits.length > 0 ) {
        bin += bits.pop().toString();
    }
    return bin;
}
/**
 * From Microsoft interview
 * calculate bitcount 
 */
function bitcount( x ) {
    var y = 0;
    while ( x ) {
        x = x & ( x - 1);
        y++;
    }
    return y;
}